/* 
 * File:   repository_tree_view.hpp
 * Author: jolo
 *
 * Created on 11. Oktober 2011, 12:08
 */

#ifndef GUI_REPOSITORY_TREE_VIEW_HPP
#define	GUI_REPOSITORY_TREE_VIEW_HPP

#include <widgets/tree_view.hpp>

namespace model
{
    class entity;
    class repository;
    class project;
    class chemical_element;

    typedef shared_ptr<entity> entity_ptr;
    typedef shared_ptr<repository> repository_ptr;
    typedef shared_ptr<project> project_ptr;
    typedef shared_ptr<chemical_element> chemical_element_ptr;
}

namespace widgets {
    class entity_item;    
}

namespace gui
{
    class repository_tree_model;
    
    class repository_tree_view : public widgets::tree_view
    {
        Q_OBJECT
    public:
        repository_tree_view(QWidget* p = 0);
        virtual ~repository_tree_view();
        virtual void setModel(repository_tree_model* m);

        repository_tree_model* custom_model() const {
            return m_;
        }
        
    signals:
        void selected(model::entity_ptr p);
        void selected(model::repository_ptr p);
        void selected(model::project_ptr p);
        void selected(model::chemical_element_ptr e);

    public slots:
        virtual void resize_columns_to_content();
        virtual void on_model_index_activated(const QModelIndex& idx);
        virtual void on_context_menu_request(const QPoint& pos);

    protected:
        virtual void handle_context_menu_for_item(widgets::entity_item* i, const QPoint& pos);
    private:
        repository_tree_model* m_;
    };
}

#endif	/* REPOSITORY_TREE_VIEW_HPP */

